Page({
  data: {
    musicInfo: {},
    musicList: []
  },
  onLoad(options) {
    wx.showLoading({
      title: '加载中...',
    })
    wx.cloud.callFunction({
      name: 'music',
      data: {
        $url: 'musiclist',
        playlistId: options.playlistId
      }
    }).then(res => {
      const result = res.result
      this.setData({
        musicInfo: {
          coverImgUrl: result.coverImgUrl,
          name: result.name
        },
        musicList: result.tracks
      })
      this.setMusicList()
      wx.hideLoading()
      console.log(result)
    })
  },
  setMusicList() {
    wx.setStorageSync('musiclist', this.data.musicList)
  }
})